//
//  TYAlertController.h
//  Somago
//
//  Created by yqc on 2021/12/13.
//  Copyright © 2021 juniu. All rights reserved.
//

#import <UIKit/UIKit.h>
@class TYAlertAction,TYAlertField;

NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSInteger, TYAlertActionType) {
    ///红色
    TYAlertActionType_default,
    ///退出
    TYAlertActionType_cancel,
    ///红色字体
    TYAlertActionType_redTitle,
};

@interface TYAlertController : UIViewController

@property (nonatomic,retain) UIView * backgroundView;
@property (nonatomic,retain) UILabel * titleLabel;
@property (nonatomic,retain) UILabel * textLabel;
@property (nonatomic,retain) UIColor * lineColor;
@property (nonatomic,retain) NSMutableArray <TYAlertAction *>* actionArray;
@property (nonatomic,retain) NSMutableArray <TYAlertField *>* fieldArray;


- (void)addAction:(TYAlertAction *)action;
- (void)addTextField:(TYAlertField *)textField;
+ (instancetype)alertWithTitle:(NSString * _Nullable)title text:(NSString * _Nullable)text;
+ (instancetype)alertWithAttributedTitle:(NSAttributedString * _Nullable)title attributedText:(NSAttributedString * _Nullable)text;

@end

@interface TYAlertAction : UIButton
@property (nonatomic,copy) void(^complete)(TYAlertAction * action);
@property (nonatomic,copy) BOOL(^shouldComplete)(TYAlertAction * action);
@property (nonatomic,weak) TYAlertController * targetVC;
@property (nonatomic,retain) UIColor * titleColor;
+ (instancetype)actionWithTitle:(NSString *)title type:(TYAlertActionType)type clickComplete:(void(^)(TYAlertAction * action))complete;
@end

@interface TYAlertField : UITextField
@property (nonatomic,copy) void(^complete)(TYAlertField * action);
@property (nonatomic,weak) TYAlertController * targetVC;
@property (nonatomic,retain) UIColor * titleColor;
+ (instancetype)actionWithText:(NSString *)text placeHolder:(NSString *)placeHolder textChange:(void(^)(TYAlertField * action))complete;
@end


NS_ASSUME_NONNULL_END
